#pragma once

class World
{
public:
    World(GameEngine& gameEngine);
    ~World();


	static const u32 cWorldWidth = 32;
    static const u32 cWorldHeight = 32;

    enum RoomType
    {
        eSleepingQuarter = 0,
        eKitchen,
        eLaboratory,
        eDirt,
        eGrass,
        e64,
        e128,

        eRoomTypeLast,
    };

private:
    enum NextRoom
    {
        eNone,
        eUp,
        eDown,
        eRight,
        eLeft
    };

public:
    bool AddRoom(RoomType type, u32 xPos, u32 yPos);
    bool AddRoom(RoomType type, const ZeEngine::Vector2D<u32>& position);

    void RemoveRoom(u32 xPos, u32 yPos);
    void RemoveRoom(const ZeEngine::Vector2D<u32>& position);
    void RemoveRoom(const Entity& room);

    bool Init(ZeEngine::GameEngine& gameEngine);

    void GetPath(const ZeEngine::Entity* pStartRoom, const ZeEngine::Entity* pEndroom, std::queue<ZeEngine::Entity*>& path);
    void GetPath(const Vector2D<s32>& startPosition, const Vector2D<s32>& endPosition, std::queue<Entity*>& path);

    Entity* GetRoom(u32 xPos, u32 yPos);
    Entity* GetRoom(const ZeEngine::Vector2D<u32>& position);

private:

    void GetAllTextures(ResourceManager& resourceManager);
    void CreateWorld();


    Entity* GetNextRoom(Entity* pRoom, NextRoom nextRoom);
    void SetRoom(u32 xTile, u32 yTile, Entity* pEntity, bool fClear = false);

private:
    SDLTexture* GetTextureFromRoom(RoomType type, ResourceManager& resourceManager);
    Entity* m_world[cWorldWidth][cWorldHeight];

    SDLTexture* m_textures[eRoomTypeLast]; 

    EntityManager& m_entityManager;

private:
};

